package com.etc.动态代理;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

/**
 * @Author 静静
 * @Description
 * @Date 2021/3/7  14:39
 **/
public class Agent implements InvocationHandler {

    private Dog dog;

    public Agent(Dog dog){
        this.dog = dog;
    }

//    @Override
//    public void sleep() {
//        System.out.println("先洗脚");
//
//
//    }

    @Override
    public Dog invoke(Object proxy, Method method, Object[] args) throws Throwable {
        System.out.println("加点肉");
        Dog result = (Dog) method.invoke(dog, args);
        System.out.println("我吃完了");
        return result;
    }
}
